package com.course.serviceImpl;

import java.util.Vector;

import com.course.bean.QueryTo;
import com.course.daoI.QueryDAOI;
import com.course.daoImpl.QueryDaoImpl;
import com.course.exception.ConnectionException;
import com.course.exception.DataNotFoundException;
import com.course.exception.LoginException;
import com.course.serviceI.QueryServiceI;

public class QueryServiveImpl implements QueryServiceI{
	
	
	
	QueryDAOI qdao=new QueryDaoImpl();
	
	
	
	Vector<QueryTo> vqto=null;
	
	boolean flag=false;

	public Vector<QueryTo> getQueries() throws DataNotFoundException {
		
		vqto=qdao.getQueries();
		
		 if (vqto.isEmpty()) {
				
				throw new DataNotFoundException();
				
			   }
			      return vqto;
		
		
		
		
	}

	public Vector<QueryTo> getQueriesAt(int qid1) throws DataNotFoundException {
		
		vqto=qdao.getQueriesAt(qid1);
		 if (vqto.isEmpty()) {
				
				throw new DataNotFoundException();
				
			   }
			      return vqto;
		
	}

	public boolean insertQuery(QueryTo qfb) throws LoginException,
			ConnectionException {
		
		flag=qdao.insertQuery(qfb);
		
		if(flag==false)
		{
			throw new ConnectionException();
			}
       else if(qfb.getQuery()==null ||qfb.getQuery().equals("")) {
			throw new LoginException();
			}
		return flag;
		
		
		
		
		
		
	}
	
	
	
	
	

}
